package br.com.estevam.sisfin.tools;

import java.io.Serializable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Util implements Serializable {
	
	private static final long serialVersionUID = -5591089507055609796L;
	
	public static synchronized boolean isNullOrEmpty(String string) {
		if (string == null) {
			return true;
		}
		if (string.trim().equals("")) {
			return true;
		}
		return false;
	}
	
	public static synchronized boolean isInteger(String num){
		try {  
			Integer.parseInt(num);
			return true;
		} catch (NumberFormatException e) {
			return false;  
		}  
	}
	
	public static String removerEspacosDuplicados(String str){
		String patternStr = "\\s+";
		String replaceStr = " ";
		Pattern pattern = Pattern.compile(patternStr);
		Matcher matcher = pattern.matcher(str);
		return matcher.replaceAll(replaceStr);
	}
}
